 
 import { verifyPhoneCaptcha, verifyEmail, verifyWithdraw, verifyMobile } from '@/utils/validateTools';
 import {i18n} from "@/languages/index.ts";
const t = i18n.global.t;
 

// 校验邮箱
 export const emailValidator = (val: any) => {
    if (verifyEmail(val)) {
        return Promise.resolve()
    } else {
        return Promise.reject(t('home_page_emailIncorrect'))
    }
}

// 校验资金密码
export const WithdrawValidator = (val: any) => {
    if (verifyWithdraw(val)) {
        return Promise.resolve()
    } else {
        return Promise.reject(t('home_page_password_fund_tips'))
    }
}

// 确认新资金密码
export const againWithdrawValidator = (val: any,new_password:any) => {
    console.log(666666)
    if (verifyWithdraw(val)&&val == new_password) {
        console.log(666666)
        return Promise.resolve()
    } else if (val != new_password) {
        return Promise.reject(t('home_page_passwordsInconsistent'))
    } else {
        return Promise.reject(t('home_page_password_fund_tips'))
    }
}

// 校验手机号码
export const mobileValidator = (value: any) => {
    if (!value) {
        return Promise.reject(t('home_page_enterPhoneNumber'))
    } else
        if (verifyMobile('84',value)) {
            return Promise.resolve()
        } else {
            return Promise.reject(t('home_page_phoneNumberFormatIncorrect'))
        }
}


// 校验验证码
export const verifyCodeValidator = (value: any) => {
    if (!value) {
        return Promise.reject(t('home_page_enterVerificationCode'))
    } else
        if (verifyPhoneCaptcha(value)) {
            return Promise.resolve()
        } else {
            return Promise.reject(t('home_page_verificationCodeFormatIncorrect'))
        }
}

// 校验邮箱验证码
export const verifyEmailValidator = (value: any) => {
    if (!value) {
        return Promise.reject(t('home_page_enterVerificationCode'))
    } else
        if (verifyPhoneCaptcha(value)) {
            return Promise.resolve()
        } else {
            return Promise.reject(t('home_page_verificationCodeFormatIncorrect'))
        }
}